import Vue from 'vue'
import App from './App.vue'
import router from '../router'
import store from '../store'

import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css'
Vue.config.productionTip = false

// import Vue from 'vue'
import * as echarts from 'echarts'
// import echarts from 'echarts'
//需要挂载到Vue原型上
Vue.prototype.$echarts = echarts

import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  ak: "rBYgd1W7n5GTRFGAxplLD7fyvN8juRlc"
})


Vue.use(Antd)

//路由导航守卫
router.beforeEach((to, from, next) => {
  store.commit('getToken')
  const token = store.state.login.token
  if (!token && to.name !== 'login') {
    next({ name: 'login' })
  } else if (token && to.name === 'login') {
    next({ name: 'home' })

  } else {
    next()
  }
})
new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
